﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Max.PH5_2010A.Shopping.DataAccess.Migrations
{
    public partial class addcategoryspec : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "CommentNumber",
                table: "tb_product_spu",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "SaleNumber",
                table: "tb_product_spu",
                type: "int",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "tb_product_category_spec",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false,defaultValueSql:"newid()"),
                    CategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SpecId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tb_product_category_spec", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "tb_product_category_spec_value",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
                    CategorySpecId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Value = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tb_product_category_spec_value", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "tb_product_spec",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tb_product_spec", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "tb_product_category_spec");

            migrationBuilder.DropTable(
                name: "tb_product_category_spec_value");

            migrationBuilder.DropTable(
                name: "tb_product_spec");

            migrationBuilder.DropColumn(
                name: "CommentNumber",
                table: "tb_product_spu");

            migrationBuilder.DropColumn(
                name: "SaleNumber",
                table: "tb_product_spu");
        }
    }
}
